# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=mplayer
pkgver=1.4.0
pkgrel=2
pkgdesc="A movie player for linux"
url="http://www.mplayerhq.hu/design7/news.html"
arch="x86_64 aarch64"
license="GPL-2.0-or-later"
subpackages="$pkgname-doc"
makedepends="libxxf86dga-dev libxv-dev libmad-dev lame-dev libao-dev
	libtheora-dev xvidcore-dev zlib-dev sdl-dev freetype-dev
	x264-dev faac-dev ttf-dejavu libxvmc-dev alsa-lib-dev live-media-dev
	mesa-dev yasm libpng-dev libvdpau-dev libvpx-dev libcdio-paranoia-dev"

source="http://www.mplayerhq.hu/MPlayer/releases/MPlayer-${pkgver%.*}.tar.xz
	x11-libs.patch
	mplayer_alpine_aarch64.patch
	"
builddir="$srcdir"/MPlayer-${pkgver%.*}
build() {
case "$CARCH" in
		aarch64)
			cpudetection="disable-runtime-cpudetection"
			;;
		*)
			cpudetection="enable-runtime-cpudetection"
	esac
	./configure \
		--prefix=/usr \
		--$cpudetection	\
		--disable-gui \
		--disable-gif \
		--disable-arts \
		--enable-x11 \
		--confdir=/etc/mplayer \
		--disable-nas \
		--enable-gl \
		--disable-tv-v4l1 \
		--enable-tv-v4l2 \
		--disable-liblzo \
		--disable-speex \
		--disable-openal \
		--disable-fribidi \
		--disable-libdv \
		--disable-musepack \
		--language=all \
		--disable-esd \
		--disable-mga \
		--disable-lirc \
		--enable-debug \
		--enable-radio \
		--enable-radio-capture \
		--extra-cflags="-I/usr/lib/live-media -O2 -fno-PIC -fno-PIE" \
		--extra-ldflags="-no-pie" \
		--disable-nemesi \
		--enable-freetype \
		--enable-xvmc
	make
}

package() {
	make -j1 DESTDIR="$pkgdir" install
	install -Dm644 etc/codecs.conf etc/input.conf etc/example.conf \
		"$pkgdir"/etc/mplayer/
	install -dm755 "$pkgdir"/usr/share/mplayer/
	ln -s /usr/share/fonts/TTF/DejaVuSans.ttf \
		"$pkgdir"/usr/share/mplayer/subfont.ttf
	rm -rf "$pkgdir"/usr/share/mplayer/font
}
sha512sums="8ef71cad187d8c8f81c837279bd3a421b440c892d3347a667670b21c954007e35cf0d15828f0901f347b9c1b053e8da4bc7f0fb6de34382d1e463074923d7b34  MPlayer-1.4.tar.xz
bba012c5a116cbc6715955a0a563c89a33a1d8ad3c44301a083ce65296ba9112a88a58e38c874d9347f9c3133054e62bd16d3b3367383f207ee40ddae105081c  x11-libs.patch
7bcb79de0627903ae1016487f9623283d3b2b186c4f2e5686093558f8d9b5d884e3357a93f43862e14fc261e587c50cd38821896ae2bdaff3f32290194fa4b55  mplayer_alpine_aarch64.patch"
